//
//  Province.m
//  1101-DopDropDownMenu-test
//
//  Created by Lang on 11/1/15.
//  Copyright © 2015 Lang. All rights reserved.
//

#import "Province.h"

@implementation Province

- (instancetype)initWithDict:(NSDictionary *)dict{
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

+ (instancetype)provinceWithDict:(NSDictionary *)dict{
    return [[self alloc]initWithDict:dict];
}

// 获取 plist 文件
+ (NSMutableArray *)provinces{
    // 1. 获取路径
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"provinces.plist" ofType:nil];
    // 2. 从 plist 文件中加载数组
    NSArray *array = [NSArray arrayWithContentsOfFile:filePath];
    
    //创建一个临时可变数组
    NSMutableArray *tempArr = [NSMutableArray arrayWithCapacity:array.count];
    
    //
    for (NSDictionary *dict in array) {
        Province *province = [self provinceWithDict:dict];
        
        [tempArr addObject:province];
    }
    
    return tempArr;
}

@end
